
<?php
//-----------------------------
//---include 
require( '../wp-load.php' );
//---get user_id
global $current_user;
get_currentuserinfo();
$user_id = $current_user->ID;
$user_login = $current_user->user_login;
//---check if login
if ( !is_user_logged_in() || $user_id<1 ) { 
	echo "<script language='javascript' type='text/javascript'>";  
	echo "$.fancybox.close();";  
	echo "</script>"; 
	exit;
} 
//-----------------------------

?>
<div class="fanbox">
    <h3>修改登陆密码</h3>
    <form id="ch_pw_form" action="order_do_user.php?action=ch_pw" method="post">
        <table width="100%" cellpadding="0" cellspacing="0" class="post_table">
            <tr>
                <td width="30%" align="right">登录用户名：</td>
                <td><?php echo $user_login; ?>
				</td>
            </tr>
			

            <tr>
                <td width="30%" align="right">登录密码：</td>
                <td>
					<input type="password" name="pass1" id="pass1" class="regular-text" size="16" value="" autocomplete="off" />
				</td>
            </tr>
            <tr>
                <td width="30%" align="right">再次输入密码：</td>
                <td>
					<input type="password" name="pass2" id="pass2" class="regular-text" size="16" value="" autocomplete="off" />
				</td>
            </tr>			
         
			
            <tr>
                <td colspan="2" align="center" >
					<input type="hidden" class="input2" name="user_id"  value="<?php echo $user_id; ?>" />
						
					<input type="submit" class="btn" value="提交"/> 
					<input type="button" class="btn" value="取消" onclick="$.fancybox.close();" />				
				</td>
            </tr>
			
			
        </table>
    </form>
</div>
<script type="text/javascript" src="js/jquery.form.js"></script>
<script type="text/javascript">
$(function(){
	$('#ch_pw_form').ajaxForm({
		beforeSubmit: validate,
		success: function(msg){
			if(msg==1){
				$.fancybox.close();				
				$().message("修改成功");
			}else{
				alert(msg);
			}
		}
	}); 
});
function validate(formData, jqForm, options) { 
	var array1 = ["pass1", "pass2"];
	var array2 = ["请输入密码","请重复一次密码"];	
	for (var i=0; i < array1.length; i++) { 		
		var ivalue = document.getElementById( array1[i] ).value;
		//alert( ivalue );		
        if ( ivalue =='' ) { 
			alert( array2[i]);
			document.getElementById( array1[i] ).focus();
            return false; 
        } 	
    }
	
	var s1 = document.getElementById("pass1").value;
	var s2 = document.getElementById("pass2").value;
	
    if ( s1 != s2 ) { 
		alert("两次输入密码不一致");
		document.getElementById("pass1").focus();
		return false; 
	}  
	$().message("正在提交...");
}
</script>